package com.jason.www.dao;

import com.jason.www.domain.Items;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ItemsMapper {
    @Delete({
        "delete from items",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into items (id, name, ",
        "price, detail, createtime, ",
        "pic)",
        "values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
        "#{price,jdbcType=REAL}, #{detail,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{pic,jdbcType=LONGVARCHAR})"
    })
    int insert(Items record);

    @InsertProvider(type=ItemsSqlProvider.class, method="insertSelective")
    int insertSelective(Items record);

    @Select({
        "select",
        "id, name, price, detail, createtime, pic",
        "from items",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="price", property="price", jdbcType=JdbcType.REAL),
        @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="pic", property="pic", jdbcType=JdbcType.LONGVARCHAR)
    })
    Items selectByPrimaryKey(Long id);

    @UpdateProvider(type=ItemsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Items record);

    @Update({
        "update items",
        "set name = #{name,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=REAL},",
          "detail = #{detail,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "pic = #{pic,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(Items record);

    @Update({
        "update items",
        "set name = #{name,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=REAL},",
          "detail = #{detail,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Items record);
}